package com.localjoycommunity.cpdj.common;

/**
 * @Function:
 * @Author: aqie
 * @Date: 2019/4/5 11:45
 */
public class CodeMsg {
    private int code;
    private String msg;


    private CodeMsg() {}

    public int getCode() {
        return code;
    }

    public String getMsg() {
        return msg;
    }


    public CodeMsg(String msg) {
        this.msg = msg;
    }

    public CodeMsg(int code, String msg) {
        this.code = code;
        this.msg = msg;
    }

    public CodeMsg fillArgs(Object... args) {
        int code = this.code;
        String message = String.format(this.msg, args);
        return new CodeMsg(code, message);
    }



    // 用户 1xxxxx
    public static CodeMsg USER_ID_NOT_EXIST_ERROR = new CodeMsg(100001, "指定id用户不存在");
    public static CodeMsg TOKEN_INVALID_ERROR = new CodeMsg(100002, "令牌不存在或者已经失效");
    public static CodeMsg USER_NAME_OR_PASSWORD_ERROR = new CodeMsg(100003, "用户名或密码错误");
    public static CodeMsg USER_NOT_EXIT_ERROR = new CodeMsg(100004, "用户名不存在");
    public static CodeMsg PASSWORD_ERROR = new CodeMsg(100005, "密码错误");
    public static CodeMsg ALREADY_SEND_SMS_ERROR = new CodeMsg(100006, "您已发送过短信");
    public static CodeMsg USER_PHONE_NOT_EXIT_ERROR = new CodeMsg(100007, "该手机号用户不存在");
    public static CodeMsg ENUM_VALUE_NOT_EXIT_ERROR = new CodeMsg(100008, "指定枚举类不存在");
    public static CodeMsg ADDRESS_ID_NOT_EXIT_ERROR = new CodeMsg(100009, "用户收货地址不合法");
    public static CodeMsg USER_EXIT_ERROR = new CodeMsg(100010, "用户已存在");
    public static CodeMsg USER_ALREADY_REGISTER_ERROR = new CodeMsg(100011, "用户已注册");

    // 商品 2xxxx
    public static CodeMsg GOOD_ID_NOT_EXIST_ERROR = new CodeMsg(200001, "指定id商品不存在");
    public static CodeMsg PRODUCT_ID_NOT_EXIST_ERROR = new CodeMsg(200002, "指定id产品不存在");
    public static CodeMsg CART_ID_NOT_EXIST_ERROR = new CodeMsg(200002, "指定id购物车记录不存在");

    // 2xx100
    public static CodeMsg WINE_ID_NOT_EXIST_ERROR = new CodeMsg(200100, "指定id酒信息不存在");

    // 服务器 5xxxxx
    public static CodeMsg SERVER_ERROR = new CodeMsg(500000, "服务端异常11");
    public static CodeMsg PARAMETER_ERROR = new CodeMsg(500101, "参数校验异常：%s");
    public static CodeMsg REQUEST_ILLEGAL = new CodeMsg(500102, "请求非法");
    public static CodeMsg ACCESS_LIMIT_REACHED = new CodeMsg(500103, "访问太频繁！");
    public static CodeMsg SMS_SERVER_ERROR = new CodeMsg(500104, "短信服务繁忙");
    public static CodeMsg MEDIA_TYPE_NOT_ACCEPT_ERROR = new CodeMsg(500105, "媒体类型不支持");
    public static CodeMsg BEAN_COPY_ERROR = new CodeMsg(500106, "实体类拷贝失败");
    public static CodeMsg NO_DATA_ERROR = new CodeMsg(500107, "暂无数据");
    public static CodeMsg NO_REQUEST_BODY_ERROR = new CodeMsg(500108, "Required request body is missing");
    public static CodeMsg NO_REQUEST_PARAM_ERROR = new CodeMsg(500109, "Required request body is missing");

    // 数据库
    public static CodeMsg DATABASE_ERROR  = new CodeMsg(500400, "数据库执行语句异常");
    public static CodeMsg DATABASE_INTEGRITY_VIOLATION_ERROR  = new CodeMsg(500401, "数据完整性的异常 不符合约束条件");
    public static CodeMsg ACCOUNT_REGISTER_ERROR = new CodeMsg(500411, "账户注册失败");
    public static CodeMsg BIND_PUSH_ID_ERROR = new CodeMsg(500412, "绑定推送ID失败");
    public static CodeMsg USER_UPDATE_ERROR = new CodeMsg(500413, "用户更新失败");

    public static CodeMsg REDIS_CONNECT_ERROR  = new CodeMsg(5007601, "reids 连接异常");
    public static CodeMsg MYSQL_CONNECT_ERROR  = new CodeMsg(5007602, "mysql 连接异常");
    public static CodeMsg MYSQL_DATA_ACCESS_RESOURCE_FAILURE_ERROR  = new CodeMsg(5007603, "客户端未检测到服务器释放连接池连接");

    // meeting
    public static CodeMsg HAS_SUBSCRIBE = new CodeMsg( "已被他人预约");
    public static CodeMsg MEETING_NOT_EXIT = new CodeMsg( "该订餐不存在");
    public static CodeMsg CANCEL_SUB_ERROR = new CodeMsg( "取消订餐失败");

    // Vote
    public static CodeMsg INVALID_VOTE_CHANNEL = new CodeMsg(200001, "投票活动ID 不合法");

}
